<?php 
if(KT!='KhiThe') exit;
class navs_controller extends navs_model{
	
	public function __construct(){
		
		global $lang;
		
		$lang['url_base'] = url_base;	
		$this->path_cur = dirname(__FILE__);	
		parent::__construct();
		parent::addObject('khithe_template');
		parent::addObject('khithe_request');
		parent::addObject('khithe_string');
		parent::addObject('khithe_images');
		
		$this->lang = $lang;
	}
	public function index()
	{
		$this->lang['li_menu'] = $this->get_categorys('0');
		$strModule = parent::khithe_display_template(dirname(__FILE__).'/navs');
		return $strModule = parent::khithe_assign($strModule, $this->lang);
	}
	
	
	public function get_categorys($ID,$SeoKey=Null,$i=0)
	{		
		$str ='';
		$query = parent::get_category($ID);
		$total = mysql_num_rows($query);
		if($total){
			$ix = $i;
			$i++;
			$str .= ($ix==0?NULL:'<ul>');
			while($row = mysql_fetch_assoc($query))
			{
                $ispage = ($row["IsPage"]=='1')?(empty($row["SeoKey"])?NULL:$row["SeoKey"].'.html'):$row["SeoKey"].'/';
				$str .='<li><a href="'.url_base . $ispage .'">'.$row["Category"].'</a>';
				$str .= $this->get_categorys($row["ID"],$row["SeoKey"],$i);
				$str .= '</li>';				
			}
			$str .= ($ix==0?NULL:'</ul>');
			
			
		}
		return $str;
	}
	


}
?>